package com.weixin.paleituo.adapter;

/**
 * Author yichao
 * Time  2017/12/12 15:57
 * Dest  ${TODO}
 */

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.weixin.paleituo.R;
import com.weixin.paleituo.activity.ImageViewHouseTypeActivity;
import com.weixin.paleituo.bean.HX;

import java.util.ArrayList;

public class HorizontalScrollViewAdapter extends AbHorizontalScrollViewAdapter<HX>
{

    public HorizontalScrollViewAdapter(Context context, ArrayList<HX> mDatas)
    {
        super(context,mDatas);
    }

    public View getView(final int position, View convertView, ViewGroup parent)
    {
        ViewHolder viewHolder = null;
        if (convertView == null)
        {
            viewHolder = new ViewHolder();
            convertView = mInflater.inflate(
                    R.layout.item_house_type, parent, false);
            viewHolder.mImg = (ImageView) convertView
                    .findViewById(R.id.id_index_gallery_item_image);
            viewHolder.mText = (TextView) convertView
                    .findViewById(R.id.id_index_gallery_item_text_type);
            viewHolder.mtextType = (TextView) convertView
                    .findViewById(R.id.id_index_gallery_item_text_housetype);

            convertView.setTag(viewHolder);
        } else
        {
            viewHolder = (ViewHolder) convertView.getTag();
        }
      //  viewHolder.mImg.setImageResource(mTS.get(position).getInteger());
        Glide.with(mContext).load(mTS.get(position).getRout()).into(viewHolder.mImg);
        viewHolder.mText.setText(mTS.get(position).getModel()+"");
        viewHolder.mtextType.setText(mTS.get(position).getSummary()+"  "+mTS.get(position).getArea());

        viewHolder.mImg.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                ImageViewHouseTypeActivity.startActivity(mContext, (ArrayList<HX>) mTS,position);
            }
        });


        return convertView;
    }

    private class ViewHolder
    {
        ImageView mImg;
        TextView mText,mtextType;

    }

}

